package com.heima.common.excepion;

import com.heima.common.dto.ResponseResult;
import com.heima.common.enums.AppHttpCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 通用异常
 *
 * @Name : BaseExceptionHandler
 * @Author : WuQiang
 * @Date : 2022-09-30 9:15
 * @Description : 通用异常
 */
@Slf4j
@RestControllerAdvice
public class BaseExceptionHandler {

    //指定捕获什么异常
    @ExceptionHandler(value = Exception.class)
    public ResponseResult handleException(Exception e) {
        e.getStackTrace();
        log.error(e.getMessage());
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }
}
